package org.begincode.admin.service;

import com.begincode.common.constant.Constant;
import com.google.common.collect.Lists;
import org.begincode.core.mapper.BlogCommentMapper;
import org.begincode.core.mapper.BlogMapper;
import org.begincode.core.model.Blog;
import org.begincode.core.model.BlogComment;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by yangsj on 2016/4/24.
 * 博文service
 */
@Service
public class BlogService {

    @Resource
    private BlogMapper blogMapper;
    @Resource
    private BlogCommentMapper blogCommentMapper;

    //获取未审核博客
    public List<Blog> selUnCheckBlogs(){
        Blog searchBlog = new Blog();
        searchBlog.setCheckFlag(Constant.UNCHECK);
        return blogMapper.selectBySelective(searchBlog);
    }
    //获取未审核评论
    public List<BlogComment> selUnCheckBlogComment(){
        BlogComment blogComment = new BlogComment();
        blogComment.setCheckFlag(Constant.UNCHECK);
        return blogCommentMapper.selectBySelective(blogComment);
    }

    //修改博客
    public int updateBlogById(Blog blog){
       return  blogMapper.updateByPrimaryKeySelective(blog);
    }

    //修改博客评论
    public int  updateBlogCommentById(BlogComment blogComment){
        return blogCommentMapper.updateByPrimaryKeySelective(blogComment);
    }
}
